this.BX=this.BX||{};(function(t,e,i){"use strict";var n,a,s;var l=function(){function t(i){var n=i.id,a=i.title,s=i.active,l=i.events,r=i.link,c=i.locked;babelHelpers.classCallCheck(this,t);this.id=n?n:null;this.title=e.Type.isString(a)?a:null;this.active=e.Type.isBoolean(s)?s:false;this.events=l?l:null;this.link=r?r:null;this.locked=e.Type.isBoolean(c)?c:false;this.linkContainer=null;this.bindEvents()}babelHelpers.createClass(t,[{key:"getTitle",value:function t(){if(!this.title){this.title=e.Tag.render(n||(n=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-nav-panel__item-title">',"</div>\t\n\t\t\t"])),this.title)}return this.title}},{key:"getContainer",value:function t(){if(!this.linkContainer){var i=this.id?'id="ui-nav-panel-item-'.concat(this.id,'"'):"";this.linkContainer=e.Tag.render(a||(a=babelHelpers.taggedTemplateLiteral(["\n\t\t\t\t<div ",' class="ui-nav-panel__item">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),i,this.title?this.getTitle():"");this.active?this.activate():this.inactivate();this.locked?this.lock():this.unLock();this.setEvents()}return this.linkContainer}},{key:"bindEvents",value:function t(){var e=this;i.EventEmitter.subscribe("BX.UI.NavigationPanel.Item:active",(function(t){if(t.data!==e){e.inactivate()}}))}},{key:"isLocked",value:function t(){return this.locked}},{key:"lock",value:function t(){this.locked=true;this.getContainer().classList.add("--locked")}},{key:"unLock",value:function t(){this.locked=false;this.getContainer().classList.remove("--locked")}},{key:"setEvents",value:function t(){var i=this;if(this.events){var n=Object.keys(this.events);var a=function t(){var e=n[l];i.getContainer().addEventListener(e,(function(){i.events[e]()}))};for(var l=0;l<n.length;l++){a()}}if(this.link){this.container=e.Tag.render(s||(s=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<a class="ui-nav-panel__item">\n\t\t\t\t\t',"\n\t\t\t\t</a>\n\t\t\t"])),this.title?this.getTitle():"");var r=Object.keys(this.link);for(var c=0;c<r.length;c++){var v=r[c];this.container.setAttribute(v,this.link[v])}}}},{key:"activate",value:function t(){this.active=true;this.getContainer().classList.add("--active");i.EventEmitter.emit("BX.UI.NavigationPanel.Item:active",this)}},{key:"inactivate",value:function t(){this.active=false;this.getContainer().classList.remove("--active");i.EventEmitter.emit("BX.UI.NavigationPanel.Item:inactive",this)}}]);return t}();var r;var c=function(){function t(i){babelHelpers.classCallCheck(this,t);this.target=e.Type.isDomNode(i.target)?i.target:null;this.items=e.Type.isArray(i.items)?i.items:[];this.container=null;this.keys=[]}babelHelpers.createClass(t,[{key:"adjustItem",value:function t(){var e=this;this.items=this.items.map((function(t){e.keys.push(t.id);return new l({id:t.id?t.id:null,title:t.title?t.title:null,active:t.active?t.active:false,events:t.events?t.events:null,link:t.link?t.link:null,locked:t.locked?t.locked:false})}))}},{key:"getItemById",value:function t(e){if(e){var i=this.keys.indexOf(e);return this.items[i]}}},{key:"getContainer",value:function t(){if(!this.container){this.container=e.Tag.render(r||(r=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-nav-panel ui-nav-panel__scope"></div>\n\t\t\t'])))}return this.container}},{key:"render",value:function t(){var i=this;this.items.forEach((function(t){if(t instanceof l){i.getContainer().appendChild(t.getContainer())}}));e.Dom.clean(this.target);this.target.appendChild(this.getContainer())}},{key:"init",value:function t(){this.adjustItem();this.render()}}]);return t}();t.NavigationPanel=c})(this.BX.UI=this.BX.UI||{},BX,BX.Event);
//# sourceMappingURL=navigationpanel.bundle.map.js